﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

using ZFB.Common;
using ZFB.IServices;

namespace ZFB.WebAPI.Controllers
{
    /// <summary>
    /// 房屋配套设施
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AttachmentsController : ControllerBase
    {
        public readonly IAttachmentsServices attachmentsServices;

        public AttachmentsController(IAttachmentsServices attachmentsServices)
        {
            this.attachmentsServices = attachmentsServices;
        }
        /// <summary>
        /// 获取全部设施
        /// </summary>
        /// <returns></returns>

        [HttpGet]
        public Task<ApiResult> GetAll() 
        {
          return attachmentsServices.GetAllAsync();
        }
        /// <summary>
        /// 添加设施
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> Add(string name, string icon) 
        {
            return await attachmentsServices.AddAsync(name, icon);
        }
        /// <summary>
        /// 删除设施
        /// </summary>
        /// <returns></returns>
        [HttpDelete]
        public async Task<ApiResult> Delete(long id) 
        {
            return await attachmentsServices.DeleteAsync(id);
        }
    }
}
